package MonthGame.problem2;

import java.util.Scanner;

public class Matrix {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        for(int i = 0;i<t;i++){
            int n = s.nextInt();
            int m = s.nextInt();
            int k = s.nextInt();
            int [][] ans = new int[n][m];
            for(int j = 0;j<k;j++){
                int x = s.nextInt()-1;
                int l = s.nextInt()-1;
                int r = s.nextInt()-1;
                while(l<=r){
                    ans[x][l]++;
                    l++;
                }
            }
            int all = 0;
            for(int i1 = 0;i1<n;i1++){
                for(int j1 = 0;j1<m;j1++){
                    all+=ans[i1][j1];
                    System.out.print(ans[i1][j1]+" ");
                }System.out.println();
            }
            if(isPrime(all)){
                System.out.println("turtle bro like it");
                System.out.println(all);
            }else System.out.println("turtle bro dislike it");
        }
    }

    static boolean isPrime(int x){
        if(x<3) return x>1;
        for(int i=2;i<x;i++) if(x%i==0) return false;
        return true;
    }
}
